package com.course.finalproject.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Class that represents a weather forecast for a single day. 
 * @author	Mariano Bessone <mariano.bessone @ tallertechnologies.com>
 * @since	2012-09-10
 */
public class WeatherForecast extends Weather implements Parcelable {

	private String weekday;
	private int highTempCel;
	private int lowTempCel;
	private int highTempFar;
	private int lowTempFar;
	private int avgHumidity;
	private int avgWindMph;
	private int avgWindKph;
	private String avgWindDir;

	/**
	 * Constructor
	 * 
	 * @param weekday The name of the day.
	 * @param highTempCel The high temperature in Celsius.
	 * @param lowTempCel The low temperature in Celsius.
	 * @param highTempFar The high temperature in Fahrenheit.
	 * @param lowTempFar The low temperature in Fahrenheit.
	 * @param avgHumidity The average humidity.
	 * @param avgWindMph The average wind velocity in Mph.
	 * @param avgWindKph The average wind velocity in Kph.
	 * @param avgWindDir The direction of the average wind.
	 */
	public WeatherForecast( String weekday, String condition, String icon, int highTempCel, int lowTempCel, int highTempFar,
							int lowTempFar, int avgHumidity, int avgWindMph, int avgWindKph, String avgWindDir) {
		super(condition, icon);
		this.weekday = weekday;
		this.highTempCel = highTempCel;
		this.lowTempCel = lowTempCel;
		this.highTempFar = highTempFar;
		this.lowTempFar = lowTempFar;
		this.avgHumidity = avgHumidity;
		this.avgWindMph = avgWindMph;
		this.avgWindKph = avgWindKph;
		this.avgWindDir = avgWindDir;
	}
	
	/**
	 * Constructor from a parcel.
	 * 
	 * @param in The parcel object to reconstruct a weather forecast object.
	 */
	private WeatherForecast(Parcel in) {
		this.weekday = in.readString();
		this.condition = in.readString();
		this.icon = in.readString();
		this.highTempCel = in.readInt();
		this.lowTempCel = in.readInt();
		this.highTempFar = in.readInt();
		this.lowTempFar = in.readInt();
		this.avgHumidity = in.readInt();
		this.avgWindMph = in.readInt();
		this.avgWindKph = in.readInt();
		this.avgWindDir = in.readString();
	}
	
	@Override
	public boolean isCurrent() {
		return false;
	}
	
	/**
	 * Returns the day for this weather forecast.
	 * 
	 * @return The name of the day for this weather forecast.
	 */
	public String getWeekDay() {
		return weekday;
	}
	
	/**
	 * Returns the high temperature in Celsius for this weather forecast.
	 * 
	 * @return The high temperature in Celsius for this weather forecast.
	 */
	public int getHighTempCel() {
		return highTempCel;
	}
	
	/**
	 * Returns the low temperature in Celsius for this weather forecast.
	 * 
	 * @return The low temperature in Celsius for this weather forecast.
	 */
	public int getLowTempCel() {
		return lowTempCel;
	}
	
	/**
	 * Returns the high temperature in Fahrenheit for this weather forecast.
	 * 
	 * @return The high temperature in Fahrenheit for this weather forecast.
	 */
	public int getHighTempFar() {
		return highTempFar;
	}
	
	/**
	 * Returns the low temperature in Fahrenheit for this weather forecast.
	 * 
	 * @return The low temperature in Fahrenheit for this weather forecast.
	 */
	public int getLowTempFar() {
		return lowTempFar;
	}
	
	/**
	 * Returns the average humidity for this weather forecast.
	 * 
	 * @return The average humidity for this weather forecast
	 */
	public int getAvgHumidity() {
		return avgHumidity;
	}
	
	/**
	 * Returns the average wind velocity in Mph for this weather forecast.
	 * 
	 * @return The average wind velocity in Mph for this weather forecast
	 */
	public int getAvgWindMph() {
		return avgWindMph;
	}
	
	/**
	 * Returns the average wind velocity in Kph for this weather forecast.
	 * 
	 * @return The average wind velocity in Kph for this weather forecast
	 */
	public int getAvgWindKph() {
		return avgWindKph;
	}
	
	/**
	 * Returns the direction of the average wind for this weather forecast.
	 * 
	 * @return The direction of the average wind for this weather forecast
	 */
	public String getAvgWindDir() {
		return avgWindDir;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(weekday);
		dest.writeString(condition);
		dest.writeString(icon);
		dest.writeInt(highTempCel);
		dest.writeInt(lowTempCel);
		dest.writeInt(highTempFar);
		dest.writeInt(lowTempFar);
		dest.writeInt(avgHumidity);
		dest.writeInt(avgWindKph);
		dest.writeInt(avgWindMph);
		dest.writeString(avgWindDir);
	}

	public static final Parcelable.Creator<WeatherForecast> CREATOR = new Parcelable.Creator<WeatherForecast>() {
		public WeatherForecast createFromParcel(Parcel in) {
		    return new WeatherForecast(in);
		}
		
		public WeatherForecast[] newArray(int size) {
		    return new WeatherForecast[size];
		}
	};

	@Override
	public String getCelTempReadable() {
		return lowTempCel + "º/" + highTempCel + "º C";
	}

	@Override
	public String getFahTempReadable() {
		return lowTempFar + "º/" + highTempFar + "º F";
	}

	@Override
	public String getHumidityReadable() {
		return "Humidity: " + avgHumidity + "%";
	}

	@Override
	public String getWindReadable() {
		return "Wind: " + avgWindKph + " Kph " + avgWindDir;
	}
	
}
